package com.kb.design.controller.chart;

import com.kb.design.common.ApiResponse;
import com.kb.design.dto.QueryChartDTO;
import com.kb.design.service.ChartService;
import com.kb.design.vo.chart.PersonProjectCount;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 报表
 */
@RestController
@RequestMapping("/chart")
public class ChartController {

    @Resource
    private ChartService chartService;
    /**
     * 当月项目数据分析
     */
    @PostMapping("/getProjectDataChart")
    public ApiResponse getProjectDataChart(@RequestBody QueryChartDTO queryChartDTO) {
        return ApiResponse.success(chartService.getProjectDataChart(queryChartDTO));
    }
    /**
     * 人员项目分配统计
     */
    @PostMapping("/personProjectCount")
    public ApiResponse personProjectCount(@RequestBody QueryChartDTO queryChartDTO) {
        Map<String, Object> map = new HashMap<>();
        List<PersonProjectCount> personProjectCounts = chartService.personProjectCount(queryChartDTO);
        map.put("itmes", personProjectCounts);
        map.put("total", personProjectCounts.size());
        return ApiResponse.success(map);
    }
    /**
     * 旭日图
     */
    @PostMapping("/risingSunMap")
    public ApiResponse risingSunMap(@RequestBody QueryChartDTO queryChartDTO) {
        Map<Object, Object> map = new HashMap<>();
        map.put("risingSunMap", chartService.risingSunMap(queryChartDTO));
        return ApiResponse.success(map);
    }

    /**
     * 甘特图
     */
    @PostMapping("/ganttChart")
    public ApiResponse ganttChart(@RequestBody QueryChartDTO queryChartDTO) {
        return ApiResponse.success(chartService.ganttChart(queryChartDTO));
    }
    /**
     * 饱和图
     */
    @PostMapping("/achievementRate")
    public ApiResponse achievementRate(@RequestBody QueryChartDTO queryChartDTO) {
        Map<String,Object> map = new HashMap<>();
        map.put("achievementRate",chartService.getAchievementRate(queryChartDTO));
        return ApiResponse.success(map);
    }
}
